<template>
	<view style="background-color: #f1f1f1;height: 100vh;">
		<view class="two">
			<u--form :model="form" ref="uForm" :rules="rules">
				<view class="two-one" style="width: 95%;margin: 0 auto;margin-top: 20rpx;">
					<u-form-item label="单号 :" labelWidth="75" prop="YNUM">
					</u-form-item>
					<u-input disabled  v-model="dataForm.YNUM"/>
				</view>
				<view class="two-one">
					<u-form-item style="padding-left: 20rpx;" label="检验员 :" labelWidth="150" prop="YJYY">
					</u-form-item>
				 </view>
				 <view style="width: 80%;margin: 0 auto;margin-top: -70rpx;margin-left: 130rpx;">
				 	<uni-combox v-model="dataForm.YJYY" :candidates="jyylist" 
				 		placeholder="请选择" emptyTips="无数据" 
				 	></uni-combox>
				 </view>
			</u--form>
		</view>
		<div >
			<view class="four-item">
				<u-button class="rgzxBox-btn2" type="primary"
				@click="submit(3)" >确认</u-button>
			</view>
		</div>
	</view>
</template>

<script>
	import { format } from 'date-fns';
	import * as dd from 'dingtalk-jsapi'

	export default {
		data() {
			return {
				dataH:{},
				tableDataAll:[],
				syqrFlg:false,
				syqrFlg2:false,
				syqrFlg3:false,
				dataForm:{},
				jyylist:[],
				form: {

					},
				loading: false,
				rules: {
				},
				test:false,
				YSNUM:'',
				YITMREFNUM:'',
			}
		},
		onLoad(query) {
			if(query.dataH){
				// 解码 JSON 字符串
				const decodedJsonString = decodeURIComponent(query.dataH);
				// 现在你可以将解码后的字符串解析为 JavaScript 对象
				this.dataH= JSON.parse(decodedJsonString);
				this.dataForm= JSON.parse(decodedJsonString);
			}
			console.log("dataH",this.dataH)
			this.userInfo = uni.getStorageSync('userInfo');
			this.init();
			this.test = uni.getStorageSync('test')||false;
			this.getjyy();
		},
		mounted() {

		  },
		methods: {
			init(){
			},
			async getjyy(){
				let GRP1 = {}
				let res = await this.$api.x3.x3request("WSLISTYDR2",GRP1)
				let cusbData = JSON.parse(res.message)
				this.jyylist=[];
				for (var i = 0; i < cusbData.GRP1.length; i++) {
					this.jyylist.push(cusbData.GRP1[i].NAME)
				}
			},
			submit(q) {
				var this_ = this
				uni.showModal({
				  title: '提示',
				  content: '是否确认？',
				  success: function (res) {
				    if (res.confirm) {
				      this_.submitData(q);
				    }
				  }
				});
			},
			async submitData(param) {
				let GRP1 = {
				  	GRP1: [{
							YFLG:2,
							YJYY:this.dataForm.YJYY,
							YNUM:this.dataForm.YNUM,
				  	}]
				  }
				let res = await this.$api.x3.x3request("WSGENPCTZ",GRP1)
				console.log("res",res)
				let resR = JSON.parse(res.message)
				if(resR.GRP3.WOK==0){
					// 显示创建成功的消息提示
					uni.showToast({
					   title: '成功:'+resR.GRP3.WRESULT,
					   icon: 'success',
					   duration: 2000
					});
				let that = this
				setTimeout(function() {
					uni.switchTab({url:"/pages/managementCenter/managementCenter"})
				}, 2000);
				}else{
					uni.showToast({
					   title: '失败:'+resR.GRP3.WRESULT,
					   icon: 'error',
					   duration: 2000
					});
				}
			},
		}
	}
</script>

<style>
.top{
	height: 100rpx;
	line-height: 100rpx;
	color: #13d5f6;
}
.two{
	background-color: white;
}
.two-one{
	overflow: hidden;
	margin-top: 20rpx;
	display: flex;
	justify-content: space-between;
}
.two-oneLeft{
	width: 190rpx;
	color: gray;
	text-align: right;
}
.two-oneRight{
	width: 350rpx;
	color: gray;
	text-align: left;
	margin-left: 10rpx;
}
.two-one1{
	overflow: hidden;
	margin-top: 20rpx;
	display: flex;
}
.two-oneLeft1{
	width: 200rpx;
	color: gray;
	text-align: right;
}
.two-oneRight1{
	color: gray;
	text-align: left;
	margin-left: 10rpx;
}
.there{
	height: 100rpx;
	line-height: 100rpx;
	color: #13d5f6;
}
.four{
	height: 120rpx;
	background-color: white;
}
.four-one{
	height: 60rpx;
	display: flex;
	justify-content: space-between;
}
.four-oneLeft{
	width: 190rpx;
	line-height: 68rpx;
	color: gray;
	text-align: right;
}
.four-oneRight{
	width: 350rpx;
	line-height: 68rpx;
	color: gray;
	text-align: left;
}
.five{
	height: 100rpx;
	line-height: 100rpx;
	color: #13d5f6;
}
.sixBox{
	height: 70rpx;
	background-color: white;
	line-height: 37rpx;
	padding-left: 40rpx;
	margin-bottom: 20rpx;
}
.four-item{
	width: 90%;
	margin-top: 16rpx;
	margin-left: 40rpx;
}
</style>
